'use strict'

module.exports = (sequelize,DataTypes)=>{
    return sequelize.define('role',{
        id: {
            type:DataTypes.INTEGER,
            allowNull: false,   //非空约束
            unique:true,  //添加唯一约束
            primaryKey:true,  //主键
            autoIncrement:true,   //自增
        },
        name:{
            type: DataTypes.STRING,
            unique:true,
        }

    },{
        // defaultScope: {   //默认查询范围
        //     limit: 2
        // },
        freezeTableName: true,  //表名不改变
        timestamps: true,  // 添加createdAt、updatedAt字段
        classMethods: {
            method1: function(){ return 'smth' }
          },
          instanceMethods: {
            method2: function() { return 'foo' }
          }
    }
    )
}

